import wave
import math
import os
import numpy as np
import matplotlib.pylab as plt

if __name__ == "__main__":
    path = os.path.abspath('.') + '/wav_files/'
    file_list = os.listdir(path)
    for file in file_list:
        file_info = os.path.splitext(file)
        file_name = file_info[0]
        file_path = path + file
        f = wave.open(file_path, 'rb')
        nframes = f.getnframes()
        framerate = f.getframerate()
        temp_data = f.readframes(nframes)
        wave_data = np.fromstring(temp_data, dtype=np.int16)
        f.close()
        time = np.arange(0, len(wave_data)) * (1.0 / framerate)
        plt.plot(time, wave_data)
        plt.savefig('result.png')
        plt.show()